/**
 * User: Obi
 * Date: 02.08.11
 * Time: 22:25
 */
package com.jediflasher.game_client.view {
import com.jediflasher.game_client.data.UniverseData;
import com.jediflasher.game_client.view.world.WorldView;

import flash.events.Event;

public class UniverseView extends BaseView {

	public function UniverseView(data:UniverseData) {
		super(data);
		this._universeData = data;
	}

	/**
	 * @private
	 */
	private var _universeData:UniverseData;

	/**
	 * @private
	 */
	private var _worldView:WorldView;

	public function get worldView():WorldView {
		return this._worldView;
	}

	override public function render(event:Event = null):Boolean {
		if (!super.render(event)) return false;

		if (!this._worldView) {
			this._worldView = new WorldView(_universeData.world);
			super.addChild(this._worldView);
		}

		return true;
	}

	override public function clear(event:Event = null):void {
		super.clear(event);

		if(this._worldView) {
			super.removeChild(this._worldView);
		}
	}
}
}
